<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>BFC</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        /*margin塌陷*/
        .outer {
            width: 400px;
            background-color: #888;

        }

        .inner {
            width: 100px;
            height: 100px;
            margin: 20px;
        }

        .inner1 {
            background-color: red;
        }

        .inner2 {
            background-color: green;
        }

        .inner3 {
            background-color: orange;
        }

        /*被浮动元素覆盖*/
        .box {
            width: 100px;
            height: 100px;
        }

        .box1 {
            background-color: red;
            float: left;
        }
        /*box1开启浮动后，box2会被box1盖住,且文字在外面*/
        .box2 {
            background-color: green;
        }

        .b {
            width: 400px;
            background-color: #888888;
        }
        .b >div {
            width: 100px;
            height: 100px;
            /*开启浮动，父元素高度就塌陷了*/
            float: left;
        }
        .b1{
            background-color: orange;
        }
        .b2{
            background-color: green;
        }
    </style>
</head>
<body>
<!--margin塌陷-->
<div class="outer">
    <div class="inner inner1">1</div>
    <div class="inner inner2">2</div>
    <div class="inner inner3">3</div>
</div>

<hr style="height: 50px;background-color: purple">

<!--被浮动元素覆盖-->
<div class="box box1">1</div>
<div class="box box2">2</div>

<hr style="height: 50px;background-color: blue">

<!--高度塌陷-->
<div class="b">
    <div class="b1">1</div>
    <div class="b2">2</div>
</div>

</body>
</html>